package table;

import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.bindings.NotNullObservable;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.windows.SimpleWindow;
import org.uqbar.arena.windows.WindowOwner;

import domain.Player;
import domain.Table;
import domain.extra.Column;
import domain.extra.FullTableException;
import domain.extra.OddEven;
import domain.extra.Result;
import domain.extra.Row;
import utilities.DummyObject;


public class RouletteSpinWindow extends SimpleWindow<Table>{
	public RouletteSpinWindow(WindowOwner parent, Table model) {
		super(parent, model);
	}

	@Override
	protected void addActions(Panel actionsPanel) {
		Button join = new Button(actionsPanel);
		join.setCaption("PayBet");
	
		join.onClick(new MessageSend(this, "paybet"));
	}
	
	public void paybet() {
		 this.getModel().betsPay(); 
		 this.close(); 
	}

	@Override
	protected void createFormPanel(Panel mainPanel) {
		this.getModel().rouletteSpin();
		Result result = this.getModel().getActualNumber(); 
		
		Label numberLabel = new Label(mainPanel);
		Label columnLabel = new Label(mainPanel);
		Label rowLabel = new Label(mainPanel);
		Label parityLabel = new Label(mainPanel);
		
		int winnerNumber = result.getNumber(); 
		Column winnerColumn = result.getColumn(); 
		Row winnerRow = result.getRow(); 
		OddEven winnerParity = result.getOddEven(); 

		numberLabel.setText("The winner number is: " + winnerNumber);
		columnLabel.setText("The winner column is: " + winnerColumn);
		rowLabel.setText("The winner row is: " + winnerRow);
		parityLabel.setText("The winner parity is: " + winnerParity);
	}

	protected void createMainTemplate(Panel formBuilder) {
		this.setTitle(" Roulette Spin ");
		super.createMainTemplate(formBuilder);
	}
}
